<template>
  <div class="edit-container">
    <el-descriptions title="个人信息：" :column="3" border>
      <el-descriptions-item labelStyle="font-weight: bold" label="姓名">{{ form.name }}</el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="性别">{{ form.sex }}</el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="⼿机号">{{ form.phone }}</el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="身份证号">{{
          form.idCards
        }}
      </el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="毕业学校">{{
          form.school
        }}
      </el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="毕业时间">{{
          form.graduationTime
        }}
      </el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="毕业时间">{{
          form.graduationTime
        }}
      </el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="银行账号">{{
          form.bankNum
        }}
      </el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="开户行">{{ form.bank }}</el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="毕业证">
        <el-image
          style="width: 100px; height: 100px"
          :src=" form.graduationUrl"
          :preview-src-list="[ form.graduationUrl]">
        </el-image>
      </el-descriptions-item>
    </el-descriptions>
    <template>
      <div class="el-descriptions">
        <div style="height: 20px;"></div>
        <div class="el-descriptions__header">
          <div class="el-descriptions__title">企业信息：</div>
          <div class="el-descriptions__extra"></div>
        </div>
      </div>
    </template>
    <el-descriptions :column="3" border>
      <el-descriptions-item labelStyle="font-weight: bold" label="企业名称">{{ form.ename }}</el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="纳税人识别号">
        {{ form.taxpayerIdentificationNumber }}
      </el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="所在部门">{{
          form.department
        }}
      </el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="岗位名称">{{
          form.postName
        }}
      </el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="企业联系电话">{{
          form.ephone
        }}
      </el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="是否全勤">{{
          form.fullAttendance
        }}
      </el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="在职证明">
        <el-image
          style="width: 100px; height: 100px"
          :src=" form.proofOfMployment"
          :preview-src-list="[ form.proofOfMployment]">
        </el-image>
      </el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="参保证明">
        <el-image
          style="width: 100px; height: 100px"
          :src=" form.proofInsuranceParticipation"
          :preview-src-list="[ form.proofInsuranceParticipation]">
        </el-image>
      </el-descriptions-item>
      <el-descriptions-item labelStyle="font-weight: bold" label="考勤明细">
        <el-image
          style="width: 100px; height: 100px"
          :src=" form.attendanceEtails"
          :preview-src-list="[ form.attendanceEtails]">
        </el-image>
      </el-descriptions-item>
    </el-descriptions>
    <template>
      <div class="el-descriptions">
        <div style="height: 20px;"></div>
        <div class="el-descriptions__header">
          <div class="el-descriptions__title">审核：</div>
          <div class="el-descriptions__extra"></div>
        </div>
      </div>
    </template>
    <el-form v-loading="formLoading" ref="form" :model="form" :rules="rules" label-width="100px">
      <el-form-item label="审核状态：" prop="humanStatus">
        <el-select v-model="form.humanStatus" placeholder="请选择">
          <el-option
            v-for="item in humanStatusList"
            :key="item.id"
            :label="item.name"
            :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="拒绝原因：" prop="humanReason" v-if="form.humanStatus === 2">
        <el-input v-model="form.humanReason" maxlength="150" placeholder="拒绝原因" type="textarea" :rows="2"/>
      </el-form-item>
      <el-form-item>
        <el-button v-loading="saveLoading"
                   element-loading-background="rgba(0, 0, 0, 0.3)" type="primary"
                   @click="handlerSubmit">保存
        </el-button>
        <el-button @click="close">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>


import {humanExamine} from "@/api/enjoyEnterpriseSubsidies";

export default {
  components: {},
  props: {
    humanEdit: {
      type: Object,
      default: () => {
        return {rules: []}
      }
    },
  },
  data() {
    return {
      form: {
        id: null,
        name: '',
        sex: '',
        phone: '',
        idCards: '',
        school: '',
        graduationTime: '',
        graduationUrl: '',
        bankNum: '',
        bank: '',
        ename: '',
        taxpayerIdentificationNumber: '',
        department: '',
        postName: '',
        ephone: '',
        fullAttendance: '',
        proofOfMployment: '',
        proofInsuranceParticipation: '',
        attendanceEtails: '',
        humanStatus: 0,
        humanReason: '',
      },
      rules: {
        humanStatus: [{required: true, trigger: 'blur', message: '请选择'}],
      },
      saveLoading: false,
      formLoading: false,
      humanStatusList: [{id: 1, name: "审核通过"}, {id: 2, name: "审核不通过"}],
    }
  },
  mounted() {
    this.form = this.humanEdit
  },
  methods: {
    handlerSubmit() {
      this.$refs.form.validate(valid => {
        if (!valid) return;
        this.saveLoading = true;
        humanExamine({
          id: this.form.id,
          humanStatus: this.form.humanStatus,
          humanReason: this.form.humanReason
        }).then(() => {
          this.$message.success('审核成功');
          this.close();
        }).finally(() => {
          this.saveLoading = false
        })
      })
    },
    close() {
      this.$emit('hideHumanEditDialog')
    },
  }
}
</script>
